package com.wut.clock.controller;

import com.wut.clock.common.api.CommonResult;
import com.wut.clock.service.IDislikeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: yuwei
 * @Date: 2022/6/13 14:33
 * @Description:
 */

@RequiredArgsConstructor
@RequestMapping("/dislike")
@RestController
@Api(value="点踩管理器",tags = {"点踩管理器"})
public class DislikeController {

    private final IDislikeService dislikeService;


    @ApiOperation("点踩")
    @PostMapping("dislike")
    public CommonResult<String> like(@RequestParam Integer entityId,
                                     @RequestParam Integer entityType,
                                     @RequestParam Integer targetUserId){
        dislikeService.dislike(entityId,entityType,targetUserId);
        return CommonResult.success();
    }

    @ApiOperation("获取实体的点踩数")
    @GetMapping("getEntityDislikeCount")
    public CommonResult<Long> getEntityDislikeCount(@RequestParam Integer entityId,
                                                    @RequestParam Integer entityType){
        return CommonResult.success(dislikeService.getEntityDislikeCount(entityId,entityType));
    }

    @ApiOperation("获取用户的被点踩数")
    @GetMapping("getUserDislikeCount")
    public CommonResult<Integer> getUserLikeCount(@RequestParam Integer userId){
        return CommonResult.success(dislikeService.getUserDislikeCount(userId));
    }

}
